﻿using System;
using System.Collections.Generic;
using Baidu.Aip.Face;
using Newtonsoft.Json.Linq;

namespace IntelligentStorWpfApp.Model
{
    public class FaceDemo
    {
        static string API_KEY = "pBmedA3luTxCCqyiLpWtWVWy", SECRET_KEY = "FQxQPbOHtEpHPOrx5Olqa2Tdpov6KRlm";
        static Face client = new Face(API_KEY, SECRET_KEY);



        public static JObject FaceDetect(byte[] ImageByte)
        {

            if (ImageByte.Length > 1024 * 1024 * 10)
                throw new Exception("图片大小必须小于10Mb");


            var options = new Dictionary<string, object>()
    {  {"max_face_num", 2},
        {"face_fields", "beauty,age,expression,gender,glasses,race"}
    };

            JObject j = client.Detect(ImageByte, options);
            if (j.Count > 0)
            {
                return j;
            }
            return null;
        }

        public static JObject IdentifyDemo(byte[] ImageByte)
        {
            var groupId = "Person";




            // 调用人脸识别，可能会抛出网络等异常，请使用try/catch捕获
            JObject result = client.Identify(groupId, ImageByte);

            if (result.Count > 0)
            {
                return result;
            }
            return null;

        }

        public static void FaceUpdate()
        {

        }

        public static void FaceDelete()
        {

        }

        public static JObject FaceMatch(byte[][] ImageByte)
        {
            JObject result = client.Match(ImageByte);
            if (result.Count > 0)
            {
                return result;
            }
            return null;
        }

        public static void FaceIdentify()
        {

        }

        public static void UserInfo()
        {

        }

        public static void GroupList()
        {

        }

        public static void GroupUsers()
        {

        }

        public static void GroupAddUser()
        {

        }

        public static void GroupDeleteUser()
        {

        }
    }
}
